﻿using Framework.Core.Util;
using Microsoft.Extensions.DependencyInjection;
using Scrutor;

namespace Framework.DI
{
	public static class DependencyInjectionExtension
	{
		/// <summary>
		/// 自动注册服务
		/// </summary>
		/// <param name="serviceCollection"></param>
		/// <param name="assemblyList"></param>
		public static void AddDependencyInjection(this IServiceCollection serviceCollection)
		{
			// 扫描服务自动化注册
			if (AssemblyUtil.GetAssemblyList().ToList() == null) return;
			var assemblyList = AssemblyUtil.GetAssemblyList().ToList();
			DynamicProxyClass.Start(serviceCollection, assemblyList, RegistrationStrategy.Replace());
		}
	}
}
